 {{include file="../tools/ueditor.htm"}}
 {{include file="../tools/timeago.htm"}} 
 
 <script>
$(function(){
	$(".timeage").timeago();
	
	var img = $(".log_content img,.rps_content img");
	img.click(function(){
		var src= $(this).attr("src");
		//var img ='<img src="'+src+'" href="'+src+'" />';
		
		$(this).colorbox({href:src});
	});
	
})
</script>

 
  {{if $is_cat_admin}}
     <textarea id="cat_log"  name="cat_log"></textarea>
     <input type="button" value="发表"  class="btn_jq" onclick="catLogAdd()"/>
     <script>
			window.UEDITOR_CONFIG.toolbars = [
					['emotion','insertimage']
					];
			
             var editor = UE.getEditor('cat_log');
			</script> 
     {{/if}}
     <a class="more" href="main.php?act=cat_log&cat_id={{$cat.cat_id}}">查看更多日志</a>
     {{foreach from=$logs item=list key=key}}
     {{$user=$list.user_info}}
     <div class="forinr review_{{$key}}">
      <div class="review_le"><span class="tximgle"><a href="category.php?cat_id={{$list.cat_id}}"><img src="{{$list.avater}}"></a></span></div>
      <div class="review_ri">
         <div class="revi_tc"><span class="bluec">{{$user.info.nick_name}}</span> <span title="{{$list.add_time}}" class="timeage">{{$list.add_time}} </span> 
         
       <!--  <a class="f_right" href="main.php?act=cat_log&cat_id={{$list.cat_id}}">More</a>-->
       
         </div>
         <div class="log_content">{{$list.content}}</div>
        
         {{if $is_cat_admin || $session.admin}} <a href="main.php?act=del_cat_log&log_id={{$list.log_id}}" class="blue">删除</a>{{/if}} <a onclick="$('.reply_{{$key}}').toggle()" class="blue">回复( {{$list.reply_num}} )</a>
         <div class="reply_div reply_{{$key}} "  style="display:none">
          <textarea class="reply" id="reply_{{$key}}" name="reply_{{$list.log_id}}"></textarea>
          <input type="button" class="btn_jq" value="回复"  onclick="replyCatLog('{{$list.log_id}}')">
        </div>
         {{foreach from=$list.reply item=slist key=skey}}
         {{$user=$slist.user_info}}
         <div class="rps {{if $skey>2}}rps_none{{/if}}" >
          <div><a href="#" class="avater"><img src="{{$slist.avater}}"></a>
             <div class="usertimein">{{$user.info.nick_name}} <em title="{{$slist.add_time}}" class="timeage">{{$slist.add_time}}</em>
             {{if $is_cat_admin || $session.admin}} <a href="main.php?act=del_cat_log&log_id={{$slist.log_id}}" class="blue">删除</a>{{/if}} 
             </div>
           </div>
          <div class="rps_content">{{$slist.content}}</div>
        </div>
         {{/foreach}}
         {{if count($list.reply)>3}}
         <div align="center">
          <input type="button" class="btn_jq" value="查看更多" onclick="$('.review_{{$key}} .rps_none').slideToggle()"/>
        </div>
         {{/if}} </div>
    </div>
     {{/foreach}} 
     <script>
			window.UEDITOR_CONFIG.toolbars = [
					['emotion','insertimage']
					];
			 var reply = $(".reply");
			 var editors = new Object;
			 for(var i=0;i<reply.length;i++)
			 {
				var ele = reply.eq(i);
				var id = ele.attr("id");
				var name = ele.attr("name");
				editors[name] = UE.getEditor(id);
			 }
			</script> 
     <script>
		 
		   
		
			 
			 function catLogAdd(){
				 if(editor.hasContents())
				 {
					var data = new Object;
					data.content = editor.getContent();
					data.cat_id = '{{$cat.cat_id}}'; 
					data.user_id = '{{$session.user_id}}'; 
					var da = "act=add_cat_log&data="+$.toJSON(data);
					Main.AJAX("ajax.php",da,catlogRes);
				 }
			 }
			 function replyCatLog(log_id){
				 var name = "reply_"+log_id;
				 var e = editors[name];
				 if(e.hasContents())
				 {
						var data = new Object;
						data.content = e.getContent();
						data.cat_id = '{{$cat.cat_id}}'; 
						data.user_id = '{{$session.user_id}}'; 
						
						data.r_id = log_id;
						var da = "act=add_cat_log&data="+$.toJSON(data);
						Main.AJAX("ajax.php",da,catlogRes); 
				 }
				
			 }
			 function catlogRes(res){
				if($.trim(res)=='1')
				{
					location.href = location.href;	
				}
			 }
			 
			
            </script>

